Ext.application({
	name : "HelloExt",
	launch : function() {
		// 判断权限菜单
		if(!userConf){
			userConf = window.parent.userConf;
		}
		function LoadMenu() {
			if (userConf) {
				var length = userConf.length;
				for (var i = 0; i < length; i++) {
					if (userConf[i].pf == '电磁辐射平台') {
						var length2 = userConf[i].funs.length;
							var html="";
						for (var int2 = 0; int2 < length2; int2++) {
							   if(userConf[i].funs[int2].name == '电磁辐射地理信息'){
							   	if(html!=""){
							   	html=html+'</br><a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/5.jpg"/></a>';
							   	}else{
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/5.jpg"/></a>';
							   	}
							   }else if(userConf[i].funs[int2].name == '电磁辐射实时数据'){
							   	if(html!=""){
							   	html=html+'</br><a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/2.jpg"/></a>';
							   	}else{
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/2.jpg"/></a>';
							   	}
							   }else if(userConf[i].funs[int2].name == '历史统计'){
							   	if(html!=""){
							   	html=html+'</br><a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/1.jpg"/></a>';
							   	}else{
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/1.jpg"/></a>';
							   	}
							   }else if(userConf[i].funs[int2].name == '基站设备'){
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/7.jpg"/></a>';
							   }else if(userConf[i].funs[int2].name == '公共投诉'){
							   	if(html!=""){
							   	html=html+'</br><a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/6.jpg"/></a>';
							   	}else{
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/6.jpg"/></a>';
							   	}
							   }else if(userConf[i].funs[int2].name == '视频播放'){
							   	if(html!=""){
							   	html=html+'</br><a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/3.jpg"/></a>';
							   	}else{
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/3.jpg"/></a>';
							   	}
							   }else if(userConf[i].funs[int2].name == '知识库'){
							   	if(html!=""){
							   	html=html+'</br><a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/4.jpg"/></a>';
							   	}else{
							   	html=html+'<a href="'+userConf[i].funs[int2].url+'" target="dcfsMain"><img src="images/4.jpg"/></a>';
							   	}
							   }
							   
							}
							    Ext.getCmp('west-region-container').add({
							    title : '电磁辐射',
								html : html
							    });
						}
					}
				}
		}
		
		// 页面跳转
		function LoadContent() {
			if (userConf) {
						var length = userConf.length;
						for (var i = 0; i < length; i++) {
							if (userConf[i].pf == '电磁辐射平台') {
								var int2 = 0;
								var length2 = userConf[i].funs.length;
								Ext.getCmp('ManCenterPanel1').body.update('<iframe id="dcfsMain" name="dcfsMain"  width="100%" height="100%" scrolling="no" frameborder="0"   src="'+userConf[i].funs[0].url+'"></iframe>');
								break;
							}
						}
					}
		}
		
		
		// 展示导航
		Ext.create('Ext.Viewport', {
			id:'mainPort',
			layout : 'border',
			items : [{
				region : 'west',
				xtype : 'panel',
				width : 220,
				collapsible : false,
				split : true,
				minSize : 220,
				id : 'west-region-container',
				title : '功能导航',
				layout : 'accordion',
				defaults : {
					bodyStyle : 'padding:15px'
				},
				layoutConfig : {
					titleCollapse : false,
					animate : true,
					activeOnTop : false
				} 
				/*items : [{
					//title : '用户管理',
					html : '<a href="userAction!gotoList" target="usermain"><img src="../images/user/yhgl.jpg"/></a>'
				}, {
					//title : '角色管理',
					html : '<a href="../role/roleAction" target="usermain"><img src="../images/user//jsgl.jpg"/></a>'
				}, {
					//title : '系统管理',
					html : '<a href="../platform/platformAction" target="usermain"><img src="../images/user/ptgl.jpg"/></a><br><a href="../function/functionAction" target="usermain"><img src="../images/user/qxgl.jpg"/></a>'
				}, {
					//title : '部门管理',
					html : '<a href="../department/departmentAction" target="usermain"><img src="../images/user/bmgl.jpg"/></a>'
				}]*/
			},{
				region : 'center',
				xtype : 'panel',
				id:'ManCenterPanel1',
				layout : 'fit',
				html:'',
				listeners : {
					afterrender : LoadContent
				} 
				 
				//userAction!gotoList
				//html : '<iframe id="usermain" name="usermain" src="'+userConf[i].funs[int2].url+'" width="100%" height="100%" scrolling="auto" frameborder="0" ></iframe>'
			}]
			
		});
		if(type=="dcfs"){
			Ext.getCmp('mainPort').add({
				region:'north',
		   		height:'51',
		   		split: false,
		   		xtype: "container",
		   		layout:'column',
		   		border: false,
				html : '<div style="background:url('+appName+'/images/header-bg.png); height:51px;"><img height="51px" width="402px" src="'+appName+'/images/logo_dcfs.png" /></div>'
			});
		}
		LoadMenu();
		LoadContent();
		setInterval(function(){
			$.ajax({
				url:"/rais/alarm/radiationAlarmAction!refesh",
				dataType:"jsonp",
				jsonpCallback:'callback',
				success:function(data){
					
				},
				error:function(xhr,error){
					
				}
			});
		},1500000);
	}
});
